package com.zhiyou.serviceImpl;

import com.zhiyou.dao.PlayDao;
import com.zhiyou.daoImpl.PlayDaoImpl;
import com.zhiyou.model.FlatPlay;
import com.zhiyou.service.PlayService;
import com.zhiyou.util.PageBean;

public class PlayServiceImpl implements PlayService {

	@Override
	public PageBean<FlatPlay> show(int pc, int ps) {
		PlayDao playDao = new PlayDaoImpl();
		PageBean<FlatPlay> pb = playDao.findAll(pc, ps);
		return pb;
	}

	@Override
	public FlatPlay find(int id) {
		PlayDao playDao = new PlayDaoImpl();
		FlatPlay play = playDao.findById(id);
		return play;
	}

	@Override
	public boolean delete(int id) {
		PlayDao playDao = new PlayDaoImpl();
		boolean flag = playDao.delete(id);
		return flag;
	}

	@Override
	public boolean update(FlatPlay flatPlay) {
		PlayDao playDao = new PlayDaoImpl();
		boolean flag = playDao.update(flatPlay);
		return flag;
	}

	@Override
	public boolean add(FlatPlay flatPlay) {
		PlayDao playDao = new PlayDaoImpl();
		boolean flag = playDao.add(flatPlay);
		return flag;
	}

	@Override
	public boolean dels(int[] id) {
		// TODO Auto-generated method stub
		PlayDao playDao = new PlayDaoImpl();
		int id1[] = playDao.dels(id);
		for(int i = 0;i<id1.length;i++){
			if(id1[i] == 0){
				return false;
			}
		}
		return true;
	}

	@Override
	public PageBean<FlatPlay> find(String place, String organizer, int pc, int ps) {
		PlayDao playDao = new PlayDaoImpl();
		PageBean<FlatPlay> pb = playDao.find(place, organizer, pc, ps);
		return pb;
	}

}
